// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   GTSIntersectionImpl.java

package com.sunwayhorizo.health.hl7.datatypes.common;

import com.sunwayhorizo.health.hl7.datatypes.BL;
import com.sunwayhorizo.health.hl7.datatypes.GTS;
import com.sunwayhorizo.health.hl7.datatypes.IVL_TS;
import com.sunwayhorizo.health.hl7.datatypes.SET_TS;
import com.sunwayhorizo.health.hl7.datatypes.TS;
import com.sunwayhorizo.health.hl7.datatypes.TYPE;

import java.util.ArrayList;


// Referenced classes of package oracle.apps.ctb.hl7.types.common:
//            GTSBase, ANYImpl, TYPEImpl

public class GTSIntersectionImpl extends GTSBase
    implements GTS
{

    public static final String RCS_ID = "$Header: GTSIntersectionImpl.java 115.13.2050.3 2006/02/09 06:27:07 mmoores noship $";
    private ArrayList _args;

    private GTS getArg(int i)
    {
        return (GTS)_args.get(i);
    }

    protected String generateLiteral()
    {
        StringBuffer stringbuffer = new StringBuffer();
        for(int i = 0; i < _args.size(); i++)
        {
            boolean flag = getArg(i).dataType().equal(com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.GTS).isTrue();
            if(flag)
                stringbuffer.append("(");
            stringbuffer.append(getArg(i).literal().stringValue());
            if(flag)
                stringbuffer.append(")");
            if(i + 1 < _args.size())
                stringbuffer.append(" ");
        }

        return stringbuffer.toString();
    }

    public TYPE dataType()
    {
        return com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.GTS;
    }

    public static GTSIntersectionImpl valueOf(GTS gts, GTS gts1)
    {
        return new GTSIntersectionImpl(gts, gts1);
    }

    private GTSIntersectionImpl cloneAndAppend(GTS gts)
    {
        return new GTSIntersectionImpl(this, gts);
    }

    private GTSIntersectionImpl(GTS gts, GTS gts1)
    {
        _args = new ArrayList();
        _args.add(gts);
        _args.add(gts1);
    }

    private GTSIntersectionImpl(GTSIntersectionImpl gtsintersectionimpl, GTS gts)
    {
        _args = (ArrayList)gtsintersectionimpl._args.clone();
        _args.add(gts);
    }

    public BL contains(TS ts)
    {
        throw ANYImpl.newUnsupportedException("GTS", "contains");
    }

    public BL contains(SET_TS set_ts)
    {
        throw ANYImpl.newUnsupportedException("GTS", "contains");
    }

    public GTS intersection(GTS gts)
    {
        return cloneAndAppend(gts);
    }

    public IVL_TS hull()
    {
        IVL_TS ivl_ts = getArg(0).hull();
        for(int i = 1; i < _args.size(); i++)
            ivl_ts = ivl_ts.intersection(getArg(i).hull());

        return ivl_ts;
    }
}
